<template>
  <el-row type="flex" align="middle" style="width:100%" :class="{title:depart.manager=='负责人'}">
    <el-col>
      <span>{{depart.name}}</span>
    </el-col>
    <el-col :span="4" align="right">
      <el-row type="flex">
        <el-col>{{depart.manager}}</el-col>
        <el-col>
          <el-dropdown>
            <span class="el-dropdown-link">
              操作
              <i class="el-icon-arrow-down el-icon--right"></i>
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item @click.native="add(depart)">添加部门</el-dropdown-item>
              <el-dropdown-item v-show="isRoot" @click.native="edit(depart.id)">编辑部门</el-dropdown-item>
              <el-dropdown-item v-show="isRoot" @click.native="del(depart.id)">删除部门</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </el-col>
      </el-row>
    </el-col>
  </el-row>
</template>

<script>
export default {
  data() {
    return {};
  },
  props: ["depart", "isRoot"],
  methods: {
    del(id) {
      this.$emit("delDepartmentById", id);
    },
    //打开表单
    add(departId) {
      this.$store.commit("depart/SET_DialogDepartId", departId);
    },
    //打开表单
    async edit(departId) {
      let result = await this.$api.department.getDepartmentById(departId)
      this.$store.commit("depart/SET_Dialog");
      this.$bus.$emit('setForm',result)
    }
  }
};
</script>

<style>
.title {
  font-weight: 600;
}
</style>